unit GL_JOURNAL_HIS;


interface
uses
  Classes,SysUtils,DB,Uni,UniEngine;

type
  TGLJOURNALHIS=class(TUniEngine)
  private
    FJOURNALID: Extended;
    FACTIONID : Extended;
    FSETYEAR  : Extended;
    FRGCODE   : string;
    FVOUID    : string;
    FVOUTYPEID: Extended;
    FBILLTYPECODE: Extended;
    FVOUMONEY : Extended;
    FSETMONTH : Extended;
    FCCID     : Extended;
    FRCID     : Extended;
    FISEND    : Extended;
    FISVALID  : Extended;
    FBILLDATE : string;
    FREMARK   : string;
    FBALVERSION: Extended;
    FCREATEDATE: string;
    FLATESTOPDATE: string;
    FLASTVER  : string;
  protected
    procedure SetParameters;override;
    function  GetStrInsert:string;override;
    function  GetStrUpdate:string;override;
    function  GetStrDelete:string;override;
  public
    function  GetStrsIndex:string;override;
  public
    function  GetNextIdex:Integer;overload;
    function  GetNextIdex(AUniConnection:TUniConnection):Integer;overload;
  public
    function  CheckExist(AUniConnection:TUniConnection):Boolean;override;
  public
    destructor  Destroy; override;
    constructor Create;  
  published
    property JOURNALID: Extended read FJOURNALID write FJOURNALID;
    property ACTIONID : Extended read FACTIONID  write FACTIONID;
    property SETYEAR  : Extended read FSETYEAR   write FSETYEAR;
    property RGCODE   : string read FRGCODE    write FRGCODE;
    property VOUID    : string read FVOUID     write FVOUID;
    property VOUTYPEID: Extended read FVOUTYPEID write FVOUTYPEID;
    property BILLTYPECODE: Extended read FBILLTYPECODE write FBILLTYPECODE;
    property VOUMONEY : Extended read FVOUMONEY  write FVOUMONEY;
    property SETMONTH : Extended read FSETMONTH  write FSETMONTH;
    property CCID     : Extended read FCCID      write FCCID;
    property RCID     : Extended read FRCID      write FRCID;
    property ISEND    : Extended read FISEND     write FISEND;
    property ISVALID  : Extended read FISVALID   write FISVALID;
    property BILLDATE : string read FBILLDATE  write FBILLDATE;
    property REMARK   : string read FREMARK    write FREMARK;
    property BALVERSION: Extended read FBALVERSION write FBALVERSION;
    property CREATEDATE: string read FCREATEDATE write FCREATEDATE;
    property LATESTOPDATE: string read FLATESTOPDATE write FLATESTOPDATE;
    property LASTVER  : string read FLASTVER   write FLASTVER;    
  public
    class function  ReadDS(AUniQuery:TUniQuery):TUniEngine;override;
    class procedure ReadDS(AUniQuery:TUniQuery;var Result:TUniEngine);override;
    class function  CopyIt(AGLJOURNALHIS:TGLJOURNALHIS):TGLJOURNALHIS;overload;        
    class procedure CopyIt(AGLJOURNALHIS:TGLJOURNALHIS;var Result:TGLJOURNALHIS);overload;       
  end;

implementation

{ TGLJOURNALHIS }
procedure TGLJOURNALHIS.SetParameters;
begin
  inherited;
  with FUniSQL.Params do
  begin
    case FOptTyp of
      otAddx:
      begin
        ParamByName('JOURNAL_ID').Value := JOURNALID;
        ParamByName('ACTION_ID').Value := ACTIONID;
        ParamByName('SET_YEAR').Value := SETYEAR;
        ParamByName('RG_CODE').Value := RGCODE;
        ParamByName('VOU_ID').Value := VOUID;
        ParamByName('VOU_TYPE_ID').Value := VOUTYPEID;
        ParamByName('BILLTYPE_CODE').Value := BILLTYPECODE;
        ParamByName('VOU_MONEY').Value := VOUMONEY;
        ParamByName('SET_MONTH').Value := SETMONTH;
        ParamByName('CCID').Value := CCID;
        ParamByName('RCID').Value := RCID;
        ParamByName('IS_END').Value := ISEND;
        ParamByName('IS_VALID').Value := ISVALID;
        ParamByName('BILL_DATE').Value := BILLDATE;
        ParamByName('REMARK').Value := REMARK;
        ParamByName('BAL_VERSION').Value := BALVERSION;
        ParamByName('CREATE_DATE').Value := CREATEDATE;
        ParamByName('LATEST_OP_DATE').Value := LATESTOPDATE;
        ParamByName('LAST_VER').Value := LASTVER; 
      end;
      otEdit:
      begin
        ParamByName('JOURNAL_ID').Value := JOURNALID;
        ParamByName('ACTION_ID').Value := ACTIONID;
        ParamByName('SET_YEAR').Value := SETYEAR;
        ParamByName('RG_CODE').Value := RGCODE;
        ParamByName('VOU_ID').Value := VOUID;
        ParamByName('VOU_TYPE_ID').Value := VOUTYPEID;
        ParamByName('BILLTYPE_CODE').Value := BILLTYPECODE;
        ParamByName('VOU_MONEY').Value := VOUMONEY;
        ParamByName('SET_MONTH').Value := SETMONTH;
        ParamByName('CCID').Value := CCID;
        ParamByName('RCID').Value := RCID;
        ParamByName('IS_END').Value := ISEND;
        ParamByName('IS_VALID').Value := ISVALID;
        ParamByName('BILL_DATE').Value := BILLDATE;
        ParamByName('REMARK').Value := REMARK;
        ParamByName('BAL_VERSION').Value := BALVERSION;
        ParamByName('CREATE_DATE').Value := CREATEDATE;
        ParamByName('LATEST_OP_DATE').Value := LATESTOPDATE;
        ParamByName('LAST_VER').Value := LASTVER; 
      end;  
      otDelt:
      begin
 
      end;  
    end;
  end;
end;

function TGLJOURNALHIS.CheckExist(AUniConnection: TUniConnection): Boolean;
begin
  Result:=CheckExist('GL_JOURNAL_HIS',[],AUniConnection);
end;

function TGLJOURNALHIS.GetNextIdex: Integer;
begin

end;

function TGLJOURNALHIS.GetNextIdex(AUniConnection: TUniConnection): Integer;
begin

end;

function TGLJOURNALHIS.GetStrDelete: string;
begin
  Result:='DELETE FROM GL_JOURNAL_HIS WHERE  ';
end;

function TGLJOURNALHIS.GetStrInsert: string;
begin
  Result:='INSERT INTO GL_JOURNAL_HIS'
         +'    ( JOURNAL_ID, ACTION_ID, SET_YEAR, RG_CODE, VOU_ID, VOU_TYPE_ID'
         +'    , BILLTYPE_CODE, VOU_MONEY, SET_MONTH, CCID, RCID, IS_END'
         +'    , IS_VALID, BILL_DATE, REMARK, BAL_VERSION, CREATE_DATE'
         +'    , LATEST_OP_DATE, LAST_VER)'
         +'    VALUES'
         +'    (:JOURNAL_ID,:ACTION_ID,:SET_YEAR,:RG_CODE,:VOU_ID,:VOU_TYPE_ID'
         +'    ,:BILLTYPE_CODE,:VOU_MONEY,:SET_MONTH,:CCID,:RCID,:IS_END'
         +'    ,:IS_VALID,:BILL_DATE,:REMARK,:BAL_VERSION,:CREATE_DATE'
         +'    ,:LATEST_OP_DATE,:LAST_VER)';
end;

function TGLJOURNALHIS.GetStrsIndex: string;
begin
  Result:=Format('',[]);
end;

function TGLJOURNALHIS.GetStrUpdate: string;
begin
  raise Exception.Create('NOT SUPPORT THIS METHOD:[TGLJOURNALHIS.GetStrUpdate] AT [GL_JOURNAL_HIS.pas]');
end;

constructor TGLJOURNALHIS.Create;
begin

end;

destructor TGLJOURNALHIS.Destroy;
begin

  inherited;
end;

class function TGLJOURNALHIS.ReadDS(AUniQuery: TUniQuery): TUniEngine;
var
  I:Integer;
  Field:TField;
  FieldName:string;
begin
  Result:=TGLJOURNALHIS.Create;

  with TGLJOURNALHIS(Result) do
  begin
    for I:=0 to AUniQuery.Fields.Count-1 do
    begin
      Field:=AUniQuery.Fields.Fields[I];
      //if field.fieldname is not all uppercase,please use uppercase().
      FieldName:=Field.FieldName;
      if FieldName='JOURNAL_ID' then
      begin
        JOURNALID:=Field.AsFloat;
      end else
      if FieldName='ACTION_ID' then
      begin
        ACTIONID :=Field.AsFloat;
      end else
      if FieldName='SET_YEAR' then
      begin
        SETYEAR  :=Field.AsFloat;
      end else
      if FieldName='RG_CODE' then
      begin
        RGCODE   :=Field.AsString;
      end else
      if FieldName='VOU_ID' then
      begin
        VOUID    :=Field.AsString;
      end else
      if FieldName='VOU_TYPE_ID' then
      begin
        VOUTYPEID:=Field.AsFloat;
      end else
      if FieldName='BILLTYPE_CODE' then
      begin
        BILLTYPECODE:=Field.AsFloat;
      end else
      if FieldName='VOU_MONEY' then
      begin
        VOUMONEY :=Field.AsFloat;
      end else
      if FieldName='SET_MONTH' then
      begin
        SETMONTH :=Field.AsFloat;
      end else
      if FieldName='CCID' then
      begin
        CCID     :=Field.AsFloat;
      end else
      if FieldName='RCID' then
      begin
        RCID     :=Field.AsFloat;
      end else
      if FieldName='IS_END' then
      begin
        ISEND    :=Field.AsFloat;
      end else
      if FieldName='IS_VALID' then
      begin
        ISVALID  :=Field.AsFloat;
      end else
      if FieldName='BILL_DATE' then
      begin
        BILLDATE :=Field.AsString;
      end else
      if FieldName='REMARK' then
      begin
        REMARK   :=Field.AsString;
      end else
      if FieldName='BAL_VERSION' then
      begin
        BALVERSION:=Field.AsFloat;
      end else
      if FieldName='CREATE_DATE' then
      begin
        CREATEDATE:=Field.AsString;
      end else
      if FieldName='LATEST_OP_DATE' then
      begin
        LATESTOPDATE:=Field.AsString;
      end else
      if FieldName='LAST_VER' then
      begin
        LASTVER  :=Field.AsString;
      end;
    end
  end;  
end;

class procedure TGLJOURNALHIS.ReadDS(AUniQuery: TUniQuery; var Result: TUniEngine);
var
  I:Integer;
  Field:TField;
  FieldName:string;
begin
  if Result=nil then Exit;

  with TGLJOURNALHIS(Result) do
  begin
    for I:=0 to AUniQuery.Fields.Count-1 do
    begin
      Field:=AUniQuery.Fields.Fields[I];
      //if field.fieldname is not all uppercase,please use uppercase().
      FieldName:=Field.FieldName;
      if FieldName='JOURNAL_ID' then
      begin
        JOURNALID:=Field.AsFloat;
      end else
      if FieldName='ACTION_ID' then
      begin
        ACTIONID :=Field.AsFloat;
      end else
      if FieldName='SET_YEAR' then
      begin
        SETYEAR  :=Field.AsFloat;
      end else
      if FieldName='RG_CODE' then
      begin
        RGCODE   :=Field.AsString;
      end else
      if FieldName='VOU_ID' then
      begin
        VOUID    :=Field.AsString;
      end else
      if FieldName='VOU_TYPE_ID' then
      begin
        VOUTYPEID:=Field.AsFloat;
      end else
      if FieldName='BILLTYPE_CODE' then
      begin
        BILLTYPECODE:=Field.AsFloat;
      end else
      if FieldName='VOU_MONEY' then
      begin
        VOUMONEY :=Field.AsFloat;
      end else
      if FieldName='SET_MONTH' then
      begin
        SETMONTH :=Field.AsFloat;
      end else
      if FieldName='CCID' then
      begin
        CCID     :=Field.AsFloat;
      end else
      if FieldName='RCID' then
      begin
        RCID     :=Field.AsFloat;
      end else
      if FieldName='IS_END' then
      begin
        ISEND    :=Field.AsFloat;
      end else
      if FieldName='IS_VALID' then
      begin
        ISVALID  :=Field.AsFloat;
      end else
      if FieldName='BILL_DATE' then
      begin
        BILLDATE :=Field.AsString;
      end else
      if FieldName='REMARK' then
      begin
        REMARK   :=Field.AsString;
      end else
      if FieldName='BAL_VERSION' then
      begin
        BALVERSION:=Field.AsFloat;
      end else
      if FieldName='CREATE_DATE' then
      begin
        CREATEDATE:=Field.AsString;
      end else
      if FieldName='LATEST_OP_DATE' then
      begin
        LATESTOPDATE:=Field.AsString;
      end else
      if FieldName='LAST_VER' then
      begin
        LASTVER  :=Field.AsString;
      end;
    end
  end;  
end;

class function  TGLJOURNALHIS.CopyIt(AGLJOURNALHIS: TGLJOURNALHIS): TGLJOURNALHIS;
begin
  Result:=TGLJOURNALHIS.Create;
  TGLJOURNALHIS.CopyIt(AGLJOURNALHIS,Result)
end;

class procedure TGLJOURNALHIS.CopyIt(AGLJOURNALHIS:TGLJOURNALHIS;var Result:TGLJOURNALHIS);
begin
  if Result=nil then Exit;
  Result.JOURNALID:=AGLJOURNALHIS.JOURNALID;
  Result.ACTIONID :=AGLJOURNALHIS.ACTIONID;
  Result.SETYEAR  :=AGLJOURNALHIS.SETYEAR;
  Result.RGCODE   :=AGLJOURNALHIS.RGCODE;
  Result.VOUID    :=AGLJOURNALHIS.VOUID;
  Result.VOUTYPEID:=AGLJOURNALHIS.VOUTYPEID;
  Result.BILLTYPECODE:=AGLJOURNALHIS.BILLTYPECODE;
  Result.VOUMONEY :=AGLJOURNALHIS.VOUMONEY;
  Result.SETMONTH :=AGLJOURNALHIS.SETMONTH;
  Result.CCID     :=AGLJOURNALHIS.CCID;
  Result.RCID     :=AGLJOURNALHIS.RCID;
  Result.ISEND    :=AGLJOURNALHIS.ISEND;
  Result.ISVALID  :=AGLJOURNALHIS.ISVALID;
  Result.BILLDATE :=AGLJOURNALHIS.BILLDATE;
  Result.REMARK   :=AGLJOURNALHIS.REMARK;
  Result.BALVERSION:=AGLJOURNALHIS.BALVERSION;
  Result.CREATEDATE:=AGLJOURNALHIS.CREATEDATE;
  Result.LATESTOPDATE:=AGLJOURNALHIS.LATESTOPDATE;
  Result.LASTVER  :=AGLJOURNALHIS.LASTVER;
end;

end.

